library(plotly)
library(crosstalk)
library(leaflet)
eqs <- highlight_key(quakes)
stations <- filter_slider("station", "Number of Stations", eqs, ~stations)
p <- plot_ly(eqs, x = ~depth, y = ~mag) %>%
add_markers(alpha = 0.5) %>%
highlight("plotly_selected")
map <- leaflet(eqs) %>%
addTiles() %>%
addCircles()
bscols(
widths = c(6, 6, 3),
p, map, stations
)
library(plotly)
#Sys.setenv('MAPBOX_TOKEN' = 'xxx')
eqs <- highlight_key(quakes)
# you need a mapbox API key to use plot_mapbox()
# https://www.mapbox.com/signup/?route-to=https://www.mapbox.com/studio/account/tokens/
map <- plot_mapbox(eqs, x = ~long, y = ~lat) %>%
add_markers(color = ~depth) %>%
layout(
mapbox = list(
zoom = 2,
center = list(lon = ~mean(long), lat = ~mean(lat))
)
) %>%
highlight("plotly_selected")
# shared properties of the two histograms
hist_base <- plot_ly(eqs, color = I("black"), histnorm = "probability density") %>%
layout(barmode = "overlay", showlegend = FALSE) %>%
highlight(selected = attrs_selected(opacity = 0.5))
histograms <- subplot(
add_histogram(hist_base, x = ~mag),
add_histogram(hist_base, x = ~stations),
nrows = 2, titleX = TRUE
)
crosstalk::bscols(histograms, map)